package top.minuy.structure.graph.network;

import top.minuy.res.graph.GraphRes;
import top.minuy.structure.graph.representations.table.WeightedGraph;

/**
 * @author Minuy
 * @time 14:14
 * @date 2021/11/29
 */
public class Test {
    public static void main(String[] args) {
        System.out.println("测试1：");
        test(GraphRes.G_MAX_FLOW_NETWORK_01,0,3);
        System.out.println("测试2：");
        test(GraphRes.G_MAX_FLOW_NETWORK_02,0,5);
        System.out.println("球队问题：");
        test(GraphRes.G_BASEBALL_01,0,10);
    }

    private static void test(String path, int s, int t) {
        WeightedGraph g = new WeightedGraph(path, true);

        MaxFlow mf = new MaxFlow(g, s, t);

        System.out.println("最大流：" + mf.maxFlow());
        for (int v = 0; v < g.V(); v++) {
            for (int w : g.adj(v)) {
                // v -> w
                System.out.println(String.format(
                        "%d->%d : %d/%d", v, w, mf.flow(v, w), g.getWeight(v, w)));
            }
        }
    }
}
